﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SPIWareMVVM.ViewModels;
using System.Windows;
using DataAccess;

namespace SPIWareMVVM.Views.Commands
{
    public class ShowProductionListCommand : BaseCommand
    {
        public ShowProductionListCommand(BaseViewModel sender) : base(sender) { }
        public override void Execute(object parameter)
        {
            if (parameter.GetType() == typeof(ProductionList))
            {
                ProductionList list = (ProductionList)parameter;
                if (list != null)
                {
                    list.lbProduction.SelectedIndex = -1;

                    if (mainWindow == null) mainWindow = (Window1)Window.GetWindow((ProductionList)list);
                    ApplicationData.ClearAllExcept(new List<Type> { typeof(MachineProduction) });
                    mainWindow.HideLists();

                    //list.machineList.lbPressMachine.ItemsSource = ApplicationData.ocMachinePresses;
                    if (list.lbProduction.Items.Count > 0) list.lbProduction.SelectedIndex = 0;
                    list.Visibility = Visibility.Visible;
                }
            }
        }
    }
}
